/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author kinder_
 */

import java.io.File;
import java.io.IOException;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;


public class mediacore {

/*
     public static void main(String[] args) {
       try {
         //Solr cell can also index MS file (2003 version and 2007 version) types.
         String fileName = "/home/kinder/Scrivania/img057.jpg";
         //this will be unique Id used by Solr to index the file contents.
         String solrId = "file:zibaldtwo:/home/kinder/Scrivania/img057.jpg";

         indexFilesSolrCell(fileName, solrId);

       } catch (Exception ex) {
         System.out.println(ex.toString());
       }
     }

     /**
  34    * Method to index all types of files into Solr.
  35    * @param fileName
  36    * @param solrId
  37    * @throws IOException
  38    * @throws SolrServerException
  39    
     public static void indexFilesSolrCell(String fileName, String solrId)
       throws IOException, SolrServerException {

       String urlString = "http://localhost:8983/solr";
       SolrServer solr = new CommonsHttpSolrServer(urlString);

       
       ContentStreamUpdateRequest up
         = new ContentStreamUpdateRequest("/update/extract");

       up.addFile(new File(fileName));

       up.setParam("literal.id", solrId);
       up.setParam("uprefix", "attr_");
       //up.setParam("fmap.content", "attr_content");

       //Sets appropriate parameters for the given ACTION
       //setAction(AbstractUpdateRequest.ACTION action,boolean waitFlush, boolean waitSearcher)
       up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);

       solr.request(up);

       QueryResponse rsp = solr.query(new SolrQuery("img057"));

       System.out.println(rsp);
     }public static void main(String[] args) {
       try {
         //Solr cell can also index MS file (2003 version and 2007 version) types.
         String fileName = "/home/kinder/Scrivania/img057.jpg";
         //this will be unique Id used by Solr to index the file contents.
         String solrId = "file:zibaldtwo:/home/kinder/Scrivania/img057.jpg";

         indexFilesSolrCell(fileName, solrId);

       } catch (Exception ex) {
         System.out.println(ex.toString());
       }
     }

     /**
  34    * Method to index all types of files into Solr.
  35    * @param fileName
  36    * @param solrId
  37    * @throws IOException
  38    * @throws SolrServerException
  39
     public static void indexFilesSolrCell(String fileName, String solrId)
       throws IOException, SolrServerException {

       String urlString = "http://localhost:8983/solr";
       SolrServer solr = new CommonsHttpSolrServer(urlString);


       ContentStreamUpdateRequest up
         = new ContentStreamUpdateRequest("/update/extract");

       up.addFile(new File(fileName));

       up.setParam("literal.id", solrId);
       up.setParam("uprefix", "attr_");
       //up.setParam("fmap.content", "attr_content");

       //Sets appropriate parameters for the given ACTION
       //setAction(AbstractUpdateRequest.ACTION action,boolean waitFlush, boolean waitSearcher)
       up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);

       solr.request(up);

       QueryResponse rsp = solr.query(new SolrQuery("img057"));

       System.out.println(rsp);
     }
  */

   }



